<!--
 * @Description: 任务审核详情
 * @Author: huacong
 * @Date: 2020-09-02 14:01:28
 * @LastEditTime: 2020-09-23 13:50:49
 * @LastEditors: huacong
-->
<template lang="pug">
  el-dialog(
    title="查房审核"
    width="840px"
    :visible="visibleDialog"
    @close="visibleDialog = false"
    :destroy-on-close="true"
    append-to-body
  )
    el-row(:gutter="24" :loading="loading")
      el-col(:span="12")
        el-card
          h2.tc.c_success(slot="header") 人脸相似度：{{info.similarity}}
          .imgBox
            h3.tc.mb10 模板照
            a-image(
              :url="info.modelUrl"
              width="100%"
              height="264px"
            )
          .desc
            p.mb5
              span.mr10 姓名：{{info.psnName}}
              span.mr10 性别：{{textFilter(info.sex, 'sex')}}
              span 出生日期：{{info.birth}}
            p.mb5
              span.mr10 医院：{{info.hospName}}
              span.mr10 拍照地点：{{info.sbmtLoc}}
              span 拍照时间：{{info.sbmtTime}}
            p
              span.mr10 入院日期：{{info.inDate}}
              span 诊断名称：{{info.diagnosis}}
      el-col(:span="12")
        el-card(:bodyStyle="{'padding-bottom': 0}")
          h2.tc(slot="header")
           span.c_error
            span {{textFilter(info.cprRslt, 'cprRslt')}}
            span.ml5(v-if="info.cprRslt === '2'") {{textFilter(info.reasonType, 'specialPhotoReason')}}
            span.ml5(v-if="info.cprRslt === '3'") {{textFilter(info.reasonType, 'specialApplyReason')}}
            el-tooltip.ml5(:content="info.remark" placement="right" effect="dark" v-if="info.remark")
              i.c_secondary(class="el-icon-question")
          .imgBox.pr
            img.chktag(:src="IMG[info.chkStas]" v-if="info.chkStas")
            h3.tc.mb10
              | 现场照
              a.ml5.c_primary(:href="info.url" v-if="info.url" target="_blank") 下载照片
            a-image(
              :url="info.url"
              width="100%"
              height="264px"
            )
          .desc
            el-form(label-width="100px")
              el-form-item(label="审核备注：")
                el-input(type="textarea" v-model="form.desc" :rows="3" v-if="!disabled")
                span(v-else) {{info.chkerMemo || '暂无'}}
    p(slot="footer" class="dialog-footer tc" v-if="!disabled")
      el-button.mr10(type="success" size="small" @click="() => submitHandle(1)") 审核通过
      el-button.mr10(type="danger" size="small" @click="() => submitHandle(2)") 移交稽核线索
      el-button.mr10(type="warning" size="small" @click="() => submitHandle(3)") 二次下发
      el-button(@click="visibleDialog = false" size="small") 取 消
</template>
<script>
import { AImage } from '@/components'
import { dictMixin } from '@/utils/mixin'
import { psnChInfo, psnChkSave} from '@/api/task'
import AUDITIMG_1 from '@/assets/audit1.png'
import AUDITIMG_2 from '@/assets/audit2.png'
import AUDITIMG_3 from '@/assets/audit3.png'
import AUDITIMG_0 from '@/assets/audit0.png'

export default {
  name:'RemoteTaskAuditInfo',
  components: {
    AImage
  },
  mixins: [dictMixin],
  props: {
    id: {
      type: [Number, String],
      default: ''
    },
    disabled: {
      type: Boolean,
      default: false
    },
    visible: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    visibleDialog: {
      get () {
        return this.visible
      },
      set (val) {
        this.$emit('update:visible', val)
      }
    }
  },
  watch: {
    visibleDialog (val) {
      if (val) {
        this.getInfo()
      }
    }
  },
  data () {
    return {
      info: {},
      loading: false,
      IMG: {
        '0': AUDITIMG_0,
        '1': AUDITIMG_1,
        '2': AUDITIMG_2,
        '3': AUDITIMG_3
      },
      form: {
        desc: ''
      }
    }
  },
  methods: {
    getInfo () {
      this.info = {}
      this.loading = true
      this.form.desc = ''
      psnChInfo({planId: this.id}).then(res => {
        if (res.respCode === 0) {
          this.info = res.respData || {}
        }
      }).finally(() => {
        this.loading = false
      })
    },
    // 审核
    submitHandle (chkStas) {
      const { form, id } = this
      psnChkSave({planId: id, chkStas, chkOpnn: form.desc}).then(res =>{
        if (res.respCode === 0) {
          this.$message.success('审核成功')
          this.$emit('getList', 'rightTable')
          this.visibleDialog = false
        }
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.desc{
  margin-top: 16px
}

.chktag{
  position: absolute;
  top: 30px;
  right: 0;
  z-index: 10;
  width: 50%;
  transform: rotate(-20deg);
}
</style>
